<?php
namespace app\demo\controller;
use think\Db;
use think\Request;
use think\Controller;
use think\Session;
class Index extends Controller
{
    public function index()
    {
        return view('login');
    }
    public function dologin(){
        $u_name=Request::instance()->param('u_name');
        $u_pwd=Request::instance()->param('u_pwd');
        $yzm=Request::instance()->param('yzm');
        $res = Db::table('user')->where(['u_name'=>$u_name])->find();
        if($res){
            if($res['u_pwd']==$u_pwd){

                Session::set('user',$res);
                return ['code'=>2,'msg'=>'登录成功'];
            }else{
                return ['code'=>1,'msg'=>'密码错误'];
            }
        }else{
            return ['code'=>0,'msg'=>'账号错误'];
        }
    }
}
